/**
 *  (c)
 *
 *
 *
 *
 */

package com.nn.smart.bus.feign;

import com.nn.smart.bus.commons.tools.constant.ServiceConstant;
import com.nn.smart.bus.commons.tools.utils.Result;
import com.nn.smart.bus.dto.UploadDTO;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * OSS
 *
 * @author Mark sunlightcs@gmail.c om
 * @since 1.0.0
 */
@FeignClient(name = ServiceConstant.BUS_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class)
public interface OssFeignClient {
    /**
     * 文件上传
     * @param file 文件
     * @return  返回路径
     */
    @PostMapping(value = "oss/upload")
    Result<UploadDTO> upload(@RequestPart("file") MultipartFile file);

    class MultipartSupportConfig {
        @Bean
        public Encoder feignFormEncoder() {
            return new SpringFormEncoder();
        }
    }

}
